package com.suitsoft.ut.commons;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.suitsoft.ut.entity.thesis.Thesis;
import com.suitsoft.ut.service.thesis.ThesisManager;

/**
 *
 *@author Suineg
 */
public class IdInitPanDuanInterceptor  implements Interceptor{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String intercept(ActionInvocation actionInvocation) throws Exception {
//		// 取得Action
//		Object action = actionInvocation.getAction();
//		String methodName = actionInvocation.getProxy().getMethod();
//		Class<?> clazz = action.getClass();
//		
//		Method method = clazz.getMethod(methodName);
//		boolean hasAnnotation = method.isAnnotationPresent(IdPanduanAnntation.class);
//		if (hasAnnotation) {
//			IdPanduanAnntation annotation = method.getAnnotation(IdPanduanAnntation.class);
//			int isPanDuanId = annotation.isIdPanduan();
//			Field f = clazz.get("thesisManager");
//			ThesisManager thesisManager = new ThesisManager();
//			System.out.println(f.getName());
//			ThesisManager thesisManagers = (ThesisManager)f.get(thesisManager);
//			Thesis thesis = thesisManagers.get(2170L);
////			if(isPanDuanId == 1){
////				if((id == null || id == 0l)){
////					Struts2Utils.getResponse().sendRedirect("/ut/lllegal");
////				}
////			}else if(isPanDuanId == 2){
////				if((id == null || id == 0l)){
////					Struts2Utils.getResponse().sendRedirect("/ut/lllegal");
////				}
////				thesis = thesisManager.get(id);
////				thesisFile = thesis.getThesisFile();
////			}
//		}
		return actionInvocation.invoke();
	}

}

